package com.kaifamiao.typehandler;

import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;

import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class BooleanTypeHandler extends BaseTypeHandler<Boolean> {
    @Override
    public void setNonNullParameter(PreparedStatement ps, int index, Boolean value, JdbcType jdbcType) throws SQLException {
        ps.setBoolean(index, value);
    }

    @Override
    public Boolean getNullableResult(ResultSet rs, String label) throws SQLException {
        return rs.getBoolean(label);
    }

    @Override
    public Boolean getNullableResult(ResultSet rs, int index) throws SQLException {
        return rs.getBoolean(index);
    }

    @Override
    public Boolean getNullableResult(CallableStatement cs, int index) throws SQLException {
        return cs.getBoolean(index);
    }

}
